<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<!DOCTYPE html>
<html>
<head>
	<jsp:include page="../inc_min.jsp"></jsp:include>
	<link rel="stylesheet" href="${ctx}/css/page.css"/>
	<link rel="stylesheet" href="${ctx}/css/npOrderQuery.css"/>
	<link rel="stylesheet" href="${ctx}/css/iconfont.css"/>
<title>订单查询-平台订单管理</title>
<script type="text/javascript">
	$(function(){
		//状态背景文字切换
		$(".listArg").click(function(){
			changeBack($(".listArg"),$(this));
		});
		$(".listArg2").click(function(){
			changeBack($(".listArg2"),$(this));
		});
		//封装函数  实现背景颜色及字体颜色切换
		function changeBack(arg,$this){
			arg.css({
				"background": "#f1f1f1",
				"color": "black"
			});
			$this.css({
				"background": "#28aaf0",
				"color": "#FFFFFF"
			});
		};

		//点击查询 重新加载列表
		$("#query").click(function(){
			 pageNum = 1;
            getData(-1,-1);
		});
        getData(-1,-1);
	});
    //获取数据
    //全局变量 总页数
    var pageNum = 1;
    function getData(orderStatus,financeStatus){
        //出发到达城市清空处理
        alsoempty($("#homecity_name"),$("#_startCity"));
        alsoempty($("#getcity_name"),$("#_endCity"));
        //获取参数
        var orderNumber=$("#_orderNumber").val();
        var pssOrderNumber=$("#_pssNumber").val();
        var toStartAirportCode=$("#_startCity").val();
        var toEndAirportCode=$("#_endCity").val();
        var toStartDate=$("#startDate").val();
        var toEndDate=$("#endDate").val();
        var buyerName=$("#buyerName").val();
        var sellerName=$("#sellerName").val();
        if(typeof(toStartAirportCode) == 'undefined'){
            toStartAirportCode = "";
        }
        if(typeof(toEndAirportCode) == 'undefined'){
            toEndAirportCode = "";
        }
        var param = {
            "orderNumber":orderNumber,
            "pssOrderNumber":pssOrderNumber,
            "orderStatus":orderStatus,
            "toStartAirportCode":toStartAirportCode,
            "toEndAirportCode":toEndAirportCode,
            "toStartDate":toStartDate,
            "toEndDate":toEndDate,
            "buyerName":buyerName,
            "sellerName":sellerName,
            "financeStatus":financeStatus,
            "page":pageNum,
            "rows":20
        }
        $.get('${ctx}/search/getPlatformList?orderType=0&temp='+Math.random(),param,function(data){
            $('table tbody').empty();
            var str = "";
            for(var i=0;i<data.rows.length;i++){
                var row = data.rows[i];
                var shouldReceiveMoney=row.sellingPrice*row.purchQuantity;
                var brokerage=shouldReceiveMoney*row.charges;
                var shouldPayMoney=shouldReceiveMoney-brokerage;
                var linkstr = '<i class="icon iconfont position" title="详情" onclick=detail("'+row.orderNumber+'")>&#xe62d;</i>'+
                				'<i class="icon iconfont position" title="日志" onclick=log("'+row.orderNumber+'")>&#xe609;</i>';
                if(row.orderStatus==0){
                    linkstr = '<i class="icon iconfont position" title="详情" onclick=detail("'+row.orderNumber+'")>&#xe62d;</i>'+
                   			  '<i class="icon iconfont position" title="日志" onclick=log("'+row.orderNumber+'")>&#xe609;</i>'+
                   			'<i class="icon iconfont position" title="取消订单" onclick=cancel("'+row.orderNumber+'")>&#xe660;</i>'
                };
                str+="<tr height='38' class='reBorder'>'"
                str+="    <td width='219' align='center'>平台："+CommonConverter.toEmptyString(row.orderNumber)+"</td>"
                str+="    <td width='629' colspan='7'>供应商："+CommonConverter.toEmptyString(row.pssOrderNumber)+"</td>"
                str+="    <td width='451' align='center'>"+linkstr+"</td>"
                str+="</tr>"
                str+="<tr height='90'>"
                str+="	<td width='186' align='left'>"
                str+="		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;往：<span style='color:black;'>"+row.list[0].airlineNumber+"</span><br/>"
                str+= (row.list.length==2) ?  "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;返：<span style='color:black;'>"+row.list[1].airlineNumber+"</span>" :  "";
                str+="	</td>"
                str+="	<td width='145' align='center'>"
                str+="		<span>"+row.list[0].deptTime+"</span><br/>"
                str+="		<span style='color:#444e50'>"+row.list[0].deptCity+"</span><span style='color:#444e50'>("+row.list[0].deptCode+")</span><span style='color:#e2615c'>"+row.list[0].deptTerminal+"</span><br/>"
                str+= (row.list.length==2) ?  "<span>"+row.list[1].arrTime+"</span><br/>" :  "";
                str+="	</td>"
                str+="	<td width='136' align='center'>"
                str+="		<span style='color:#23b9dc'>"+row.list[0].deptDate+"</span><br/>"
                str+= (row.list.length==2) ?  "<img src='${ctx}/image/flightQuery/round.gif'>" :  "<img src='${ctx}/image/flightQuery/dancheng.png'>";
                str+= (row.list.length==2) ?  "<span style='color:#23b9dc'>"+row.list[1].deptDate+"</span><br/>" :  "";
                str+="	</td>"
                str+="	<td width='156'>"
                str+="		<span>"+row.list[0].arrTime+"</span><span style='color:#e2615c;'>+"+row.list[0].intervalDay+"<br/>"
                str+="		<span style='color:#444e50'>"+row.list[0].arrCity+"</span><span style='color:#444e50'>("+row.list[0].arrCode+")</span><span style='color:#e2615c'>"+row.list[0].arrTerminal+"</span><br/>"
                str+= (row.list.length==2) ?  "<span>"+row.list[1].deptTime+"</span><br/>" :  "";
                str+="	</td>"
                str+="	<td width='178'>"
                str+="		卖家：<span class='redText'>"+CommonConverter.toEmptyString(row.sellerName)+"</span><br/>"
                str+="		买家：<span class='blueText'>"+CommonConverter.toEmptyString(row.buyerName)+"</span><br/>"
                str+="		姓名：<span class='blackText'>"+CommonConverter.toEmptyString(row.createuserName)+"</span><br/>"
                str+="		电话：<span class='blackText'>"+CommonConverter.toEmptyString(row.mobile)+"</span>"
                str+="	</td>"
                str+="	<td width='49' align='center' style='color:#23b9dc'>"+row.purchQuantity+"</td>"
                str+="	<td width='400' >"
                str+="		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;下单：<span class='blackText'>"+row.orderCreateTime+"</span><br/>"
                str+="		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;支付：<span class='blackText'>"+CommonConverter.toEmptyString(row.payTime)+"</span><br/>"
                str+="		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;名单：<span class='blackText'>"+CommonConverter.toEmptyString(row.passengerUptime)+"</span><br/>"
                str+="		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;出票：<span>"+CommonConverter.toEmptyString(row.ticketOuttime)+"</span>"
                str+="	</td>" 
                str+="	<td width='145' align='center'>"
                str+="		应收金额：<span class='blueText'>￥"+shouldReceiveMoney+"</span><br/>"
                str+="		佣金：<span class='orangeText'>￥"+brokerage+"</span><br/>"
                str+="		应付金额：<span class='redText'>￥"+shouldPayMoney+"</span><br/>"
                str+="	</td>"
                str+="	<td width='104' align='center'>"
                str+="		<span class='blueText'>"+CommonConverter.toOrderBizStatusStr(row.orderStatus)+"</span><br/>"
                str+="		<span class='redText'>"+CommonConverter.toOrderPayStatusStr(row.financeStatus)+"</span>"
                str+="	</td>"
                str+="</tr>"
            }
            $('#tb').append(str);
            //显示分页
            layui.use(['laypage', 'layer'], function(){
                var laypage = layui.laypage;
                laypage({
                    cont: 'pager'
                    ,pages: Math.ceil(data.total/20) //得到总页数 //总页数
                    ,groups: 5 //连续显示分页数
                    ,skin: '#1E9FFF'
                    ,curr : pageNum
                    ,jump: function(obj,first){
                        if(!first){
                            pageNum = obj.curr;
                            getData(orderStatus,financeStatus);
                        }
                    }
                });
            });
        })
    }
	//查看详情
	function detail(orderNumber){
		window.location.href='${ctx}/order/detail/'+orderNumber;
	};
	//查看日志
	function log(orderNumber){
		layer.open({
			type: 2,
			title: ['订单操作记录','background-color:#00B2EE; color:#fff;'],
			shadeClose: true,
			shade: 0.5,
			area: ['750px', '450px'],
			content: ['${ctx}/nporder/logs/'+orderNumber, 'no'],
			success: function(layero, index){
			},
			end:function(){
			}
		});
	};
	//取消订单
	function cancel(orderNumber){
		layer.confirm("确认要取消订单【"+orderNumber+"】吗？"
			, {title:['取消订单','background-color:#00B2EE; color:#fff;'],area: ['400px', '150px']}
			, function(index){
				layer.open({
					type: 2,
					title: ['取消订单','background-color:#00B2EE; color:#fff;'],
					shadeClose: true,
					shade: 0.5,
					area: ['500px', '380px'],
					content: ['${ctx}/nporder/cancel/'+orderNumber, 'no'],
					success: function(layero, index){
					},
					end:function(){
					}
				});
				  
				layer.close(index);
			}
		);
	};
	//如果为空  对应的文本框为空
	function alsoempty(a,b){
		if(a.val() == "中文/拼音"){
			b.val("");
		};
	};
</script>
</head>
<body>
<jsp:include page="../head.jsp"></jsp:include>
		 <div class="content">
		 	<div class="list">
		 		<ul class="listBox">
					<li>平台订单号：<input  id="_orderNumber" name="charterType" class="easyui-textbox"/></li>
					<li>供应商订单号：<input  id="_pssNumber" name="charterType" class="easyui-textbox"/></li>
					<li>采购商：<input  id="buyerName" name="charterType" class="easyui-textbox"/></li>
					<li>供应商：<input  id="sellerName" name="charterType" class="easyui-textbox"/></li>
					<li>
						出发时间 ：<input type="text" style="height:18px;" id="startDate" class="textbox" value="${requestScope.deptDate}" onFocus="new WdatePicker({dateFmt:'yyyy-MM-dd'})"/>
						<img class="city" src="${ctx}/image/date.gif">&nbsp;&nbsp;&nbsp;&nbsp;
						至<input type="text" style="height:18px;" id="endDate" class="textbox" value="${requestScope.endDate}" onFocus="new WdatePicker({dateFmt:'yyyy-MM-dd'})">
						<img class="city" src="${ctx}/image/date.gif">
					</li>
					<li>出发城市：
					<input type="text" value=""  size="15" id="homecity_name" name="homecity_name" style="width:150px;" mod="address|notice" mod_address_source="hotel" mod_address_suggest="" mod_address_reference="_startCity" mod_notice_tip="中文/拼音" />
					<input id="_startCity" name="_startCity" type="hidden" value="" />
					</li>
					<li>到达城市：
					<input type="text" value=""  size="15" id="getcity_name" name="getcity_name" style="width:150px;" mod="address|notice" mod_address_source="hotel"  mod_address_reference="_endCity" mod_notice_tip="中文/拼音" />
					<input id="_endCity"  name="_endCity" type="hidden" value="" />
					</li>
					<li class="right"><button class='query' id="query">查询</button></li>
				</ul>
				
		 	</div>
			<ul class="conditionList">
				<li>业务状态：</li>
				<li class="listArg allStatus" onclick="getData(-1,-1)"><span>全部</span></li>
				<li class="listArg" onclick="getData(0,-1)"><span>待支付</span></li>
				<li class="listArg" onclick="getData(2,-1)"><span>待出票</span></li>
				<li class="listArg" onclick="getData(4,-1)"><span>出票完成</span></li>
				<li class="listArg" onclick="getData(5,-1)"><span>已取消</span></li>
			</ul>
			<ul class="conditionList conditionFince">
				<li>财务状态：</li>
				<li class="listArg2 allStatus" onclick="getData(-1,-1)"><span>全部</span></li>
				<li class="listArg2" onclick="getData(-1,1)"><span>收款待审核</span></li>
				<li class="listArg2" onclick="getData(-1,2)"><span>已收款</span></li>
				<li class="listArg2" onclick="getData(-1,3)"><span>待提现</span></li>
				<li class="listArg2" onclick="getData(-1,4)"><span>提现待审核</span></li>
				<li class="listArg2" onclick="getData(-1,5)"><span>提现待支付</span></li>
				<li class="listArg2" onclick="getData(-1,6)"><span>已付款</span></li>
			</ul>
		 <table class="conTable">
		 	<thead>
		 		<tr height="38" >
					<td width="186" align="center"><img src="${ctx}/image/flightQuery/flightNumber.gif">航班号</td>
					<td width="145" align="center"><img src="${ctx}/image/flightQuery/flightStart.gif">出发/到达</td>
					<td width="115" align="center">&nbsp;&nbsp;&nbsp;</td>
					<td width="175"><img src="${ctx}/image/flightQuery/flightEnd.gif">到达/出发</td>
					<td width="118" >供应商/采购商</td>
					<td width="49" align="center">数量</td>
					<td width="222" align="center">时间点</td>
					<td width="155" align="center">支付明细</td>
					<td width="74" align="center">状态</td>
				</tr>
		 	</thead>
			<tbody  id="tb">
			</tbody>
		</table>
         <!-- 分页 -->
         <div id="pager" class="divBox"></div>
         </div>
	<script type="text/javascript" src="${ctx }/jslib/airport/fixdiv.js"></script>
	<script type="text/javascript" src="${ctx }/jslib/airport/address.js"></script>
	<jsp:include page="../footer.jsp"></jsp:include>
</body>
</html>